<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="back" action="customer/list" label="#{msgs['toolbar.back']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
                <t:separator />
                <!-- Granularity selection -->
                <t:icon iconName="more" action="more" backingBean="#{projectManager}" label="#{msgs['toolbar.more']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="moreNavLink"
                        renderedBean="#{projectManager.paginator}" renderedAction="moreSafe" />
                <t:icon iconName="less" action="less" backingBean="#{projectManager}" label="#{msgs['toolbar.less']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lessNavLink"
                        renderedBean="#{projectManager.paginator}" renderedAction="remainsSomething" />
                <t:separator />
                <!-- AJAX navigation -->
                <t:icon iconName="first" action="first" backingBean="#{projectManager}" label="#{msgs['toolbar.first']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="firstNavLink"
                    renderedBean="#{projectManager.paginator}" renderedAction="hasPreviousPage" />
                <t:icon iconName="prev" action="previous" backingBean="#{projectManager}" label="#{msgs['toolbar.previous']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="prevNavLink"
                    renderedBean="#{projectManager.paginator}" renderedAction="hasPreviousPage" />
                <t:textIcon>
                    <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}">
                        <f:param value="#{projectManager.paginator.pageFirstItem + 1}" />
                        <f:param value="#{projectManager.paginator.pageLastItem + 1}" />
                        <f:param value="#{projectManager.paginator.itemsCount}" />
                    </h:outputFormat>
                    <h:outputText value=" (#{msgs['app.paging.page']} #{projectManager.paginator.actualPage + 1}) " />
                </t:textIcon>
                <t:icon iconName="next" action="next" backingBean="#{projectManager}" label="#{msgs['toolbar.next']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="nextNavLink"
                    renderedBean="#{projectManager.paginator}" renderedAction="hasNextPage" />
                <t:icon iconName="last" action="last" backingBean="#{projectManager}" label="#{msgs['toolbar.last']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lastNavLink"
                    renderedBean="#{projectManager.paginator}" renderedAction="hasNextPage" />
            </t:toolbar>
        </ui:define>

        <!-- Title -->
        <ui:define name="content-title">
            <h1>#{msgs["user.customer.detail.title"]}</h1>
        </ui:define>

        <!-- Content -->
        <ui:define name="content">
            <c:if test="#{customerManager.customer.id == -1}">
                <script type="text/javascript" language="JavaScript">
                   window.location="list.jsf";
                </script>
            </c:if>
            

           <br />
           <h:outputStylesheet name="cssDetail.css" library="css" />
           <h:panelGrid columns="2" styleClass="panelDetail">
               <h:outputLabel>#{msgs["user.customer.detail.title"]}</h:outputLabel>
             <h:outputLabel>#{customerManager.customer.name}</h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.companyICO"]}</h:outputLabel>
             <h:outputLabel>
                 #{customerManager.customer.ic}
             </h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.companyDIC"]}</h:outputLabel>
             <h:outputLabel>
                 #{customerManager.customer.dic}
             </h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.address"]}</h:outputLabel>
             <h:outputLabel>
                 #{customerManager.customer.address} <br />
                 #{customerManager.customer.zipCode}&nbsp;&nbsp;#{customerManager.customer.city}
             </h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.email"]}</h:outputLabel>
             <h:outputLabel><a href="mailto:#{customerManager.customer.email}">
                     #{customerManager.customer.email}</a></h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.phone"]}</h:outputLabel>
             <h:outputLabel>#{customerManager.customer.phone}</h:outputLabel>

             <h:outputLabel>#{msgs["user.customer.detail.rateType"]}</h:outputLabel>
             <c:choose>
                <c:when test="#{customerManager.customer.rateType == 'p'}">
                    <h:outputLabel>#{msgs["project.rateType.project"]}</h:outputLabel>
                </c:when>
                <c:when test="#{customerManager.customer.rateType == 'h'}">
                    <h:outputLabel>#{msgs["project.rateType.hours"]}</h:outputLabel>
                </c:when>
                <c:when test="#{customerManager.customer.rateType == 't'}">
                    <h:outputLabel>#{msgs["project.rateType.tariff"]}</h:outputLabel>
                </c:when>
             </c:choose>

             <h:outputLabel>#{msgs["project.note"]}</h:outputLabel>
             <h:outputLabel>#{customerManager.customer.note}</h:outputLabel>

           </h:panelGrid>

            <c:choose>
                <c:when test="#{projectManager.customerProjectCount > 0}">
                    <br />
                    <h2><h:outputLabel styleClass="">#{msgs["user.customer.detail.project"]}</h:outputLabel></h2>

                    <!-- Task Listing -->
                    <h:outputStylesheet name="cssTable.css" library="css" />
                    <h:dataTable id="projectTable"
                                 value="#{projectManager.listCustomer}"
                                 var="project"
                                 styleClass="listing"
                                 rowClasses="odd,even"
                                 columnClasses="name, note, pricePerRateUnit, time, actions">
                        <t:column  headerCssStyle="listing-header" entity="${project}"
                               fieldName="name" backingBean="#{projectManager}"
                               label="#{msgs['user.project.list.name']}">
                            <h:commandLink action="#{projectManager.detail}">
                                #{project.name}
                            </h:commandLink>
                            <f:verbatim rendered="#{project.isActive == 'n'}">
                                <span style="font-size: 0.8em; color:red;">(#{msgs['user.project.list.activeFalse']})</span>
                            </f:verbatim>
                        </t:column>
                        <t:column  sort="false" entity="${project}"
                                   fieldName="note" backingBean="#{projectManager}"
                                   label="#{msgs['user.project.list.description']}">
                            #{project.note}
                        </t:column>
                        <t:column  entity="${project}"
                                   fieldName="timeEstimation" backingBean="#{projectManager}"
                                   label="#{msgs['user.project.list.timeEstimation']}">
                            #{project.timeEstimation}
                       </t:column>
                       <t:column entity="#{project}" fieldName="rateType"
                                  backingBean="#{projectManager}"
                                  label="#{msgs['user.project.list.rateType']}">
                            #{project.rateType}
                       </t:column>
                       <t:column entity="#{project}" fieldName="pricePerRateUnit"
                                  backingBean="#{projectManager}"
                                  label="#{msgs['user.project.list.pricePerRateUnit']}">
                            #{project.pricePerRateUnit} #{msgs['app.currency']}
                       </t:column>
                       <t:columnCommand label="#{msgs['user.project.list.actions']}">
                            <h:commandButton value="#{msgs['user.project.list.actions.edit']}" action="#{projectManager.edit}" />
                            <h:commandButton value="#{msgs['user.project.list.actions.newtask']}" action="#{projectManager.newTask}" />
                            <h:commandButton value="#{msgs['user.project.list.actions.detail']}" action="#{projectManager.detail}" />
                       </t:columnCommand>
                    </h:dataTable>

                    <!-- AJAX navigation -->
                    <h:commandLink id="prevLink" action="#{projectManager.previous}"
                                    value="Previous #{projectManager.paginator.pageSize}"
                                    rendered="#{projectManager.paginator.hasPreviousPage}">
                        <f:ajax execute="@this" render="@all" />
                    </h:commandLink>

                    <h:outputText value="#{projectManager.paginator.pageFirstItem + 1} to #{projectManager.paginator.pageLastItem + 1} of #{projectManager.paginator.itemsCount}"/>
                    <h:outputText value=" Page: #{projectManager.paginator.actualPage + 1} " />

                    <h:commandLink id="nextLink" action="#{projectManager.next}"
                                   value="Next #{projectManager.paginator.pageSize}"
                                   rendered="#{projectManager.paginator.hasNextPage}">
                        <f:ajax execute="@this" render="@all" />
                    </h:commandLink>
                </c:when>
                <c:otherwise>
                    <p class="warning-messages-noitems">
                        #{msgs['app.listing.no-records']}
                    </p>
                </c:otherwise>
            </c:choose>

           <div class="info-messages">
                <h3>#{msgs['user.generic.legend']}</h3>

                <ul>
                    <li>#{msgs['user.generic.rateType-h']}</li>
                    <li>#{msgs['user.generic.rateType-p']}</li>
                    <li>#{msgs['user.generic.rateType-t']}</li>
                </ul>
           </div>

       </ui:define>

    </ui:composition>

</h:body>
</html>
